Modern applications
are often split into multiple services and
in some instances, each of these services
is created to handle specific tasks within
the application. In this module, we'll
discuss ways to allow these different services to
communicate with each other. A common way to use
Cloud Run is to deploy one service connected to
multiple back-ends and APIs. In this example of an
e-commerce website, the product and orders
are stored in Cloud SQL. The user sessions are
persisted in Memorystore and a third-party API is
used to deliver email. This is a popular and valid way to design and build
applications. It can work well if you're a small business and you're
just getting started, it can also work well if
you run software at scale. There are many examples of
successful companies that use a design similar to this to
build their applications. However, there are other ways to design your application. Another way is to use multiple services that have
distinct responsibilities. That is a microservice
architecture. Doing so might result
in several benefits; Improved scalability because every service can
scale independently. Improved collaboration
and development speed if distributed teams build and deploy their own
services independently. Increased robustness
if one service breaks another service
can continue to work. There were various
trade-offs involved in making this architectural
design choice. Cloud Run supports
both design patterns, but you are limited to the
system resources that are available on a
per-container basis. Cloud Run does not
require you to break down your application into multiple
services but if you do, you need a way for
those services to communicate and that's
the topic of this module. We'll discuss the various
options you have for service-to-service
communication and how to make the most of them. I'll cover two basic patterns of service of communication
in this module. Request and Response means one service sends a request and waits for a response
to be returned. This is called synchronous
because the sender waits until the request
successfully completes. Publish and Subscribe,
on the other hand, is used where you don't need
to wait for the result. You can use an
asynchronous approach. With Publish and
Subscribe one service sends or publishes a message to a Message Broker
that then copies and forwards the message to one
or more of the subscribers. In this module, you'll
learn to use Pub/Sub, a message broker to asynchronously send
messages between services. Send direct requests between Cloud Run services if you
don't know the URL beforehand. Receive events from other
Google Cloud services, such as Cloud Storage, and process background tasks asynchronously using
Pub/Sub or Cloud Tasks.